package com.ysd.dao.impl;



import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.tjXinWen;
import com.ysd.util.DBManger;

public class tjXinWen2DaoImpl {
	public List<tjXinWen> gettjXinWenList(){
		List<tjXinWen> tjxwList = new ArrayList<tjXinWen>();
		Connection conn = DBManger.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		
		try {
			st=conn.createStatement();
			rs=st.executeQuery("SELECT * FROM tjxinwenbiao ORDER BY RAND() limit 4");
			while(rs.next()) {
				int tjxwId=rs.getInt("tjXinWenId");
				String tjxwbt=rs.getString("tjXinWenBiaoTi");
				String tjxwnr=rs.getString("tjXinWenNeiRong");
				tjXinWen tjxw = new tjXinWen(tjxwId, tjxwbt, tjxwnr);
				tjxwList.add(tjxw);
			}
			return tjxwList;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManger.closeAll(conn, st, rs);
		}
		
	}
	}
